package com.zsz.springboot.web;


import com.alibaba.dubbo.config.annotation.Reference;
import com.zsz.springboot.model.Student;
import com.zsz.springboot.service.StudentService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class StudentController {

    @Reference(interfaceClass = StudentService.class, version = "1.0.0", check = false)
    private StudentService studentService;

    @RequestMapping(value = "/student/detail/{id}")
    public String studentDetail(Model model,
                                @PathVariable("id") Integer id) {

        //根据学生id查询详情
        Student student = studentService.queryStudentById(id);

        model.addAttribute("student", student);


        return "studentDetail";

    }

    @RequestMapping(value = "/count/detail/count")
    @ResponseBody
    public Object studentCount() {

        //查询所有的学生人数
        Integer count = studentService.queryStudentCount();


        return "学生总人数为："+count;
    }

}
